<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script type="text/javascript" src="${ctx}/commons/js/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css" href="${ctx}/commons/js/uploadify/uploadify.css" rel="stylesheet"></link>

<style type="text/css">
	li{
		padding-top:8px;
	}
	.st{
	 display:none;
	}
	#viewDate{
		
	}
</style>
<script type="text/javascript">
     var requestUrl="http://${basePath}:${port}${ctx}/business/projectmanage/leader/makeFileInput?projectId=${project.id}&r="+new Date().getTime();
</script>
<form name="addProjectsDataForm" id="addDataForm" method="post" action=""  style="padding:6px;">
	<input type="hidden" name="id" id="id" value="${project.id}"/>
	<input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/>
	
	<div class="easyui-panel" data-options="border:true,title:'响应文件'" style="padding:6px;margin-bottom: 6px;">
		<table class="infoTable">
			<tbody>
				<tr>
					<th  align='center' width="15%">评审纪要 </th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue11" class="fileQueue" flag="11" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify11" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==11}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				
				<tr>
					<th  align='center' width="15%">竞价文件评审表 </th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue12" class="fileQueue" flag="12" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify12" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==12}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				
				<tr>
					<th  align='center' width="15%">评审专家、监督员签到表</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue13" class="fileQueue" flag="13" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify13" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==13}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				
				<tr>
					<th  align='center' width="15%">询标函</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue14" class="fileQueue" flag="14" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify14" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==14}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				
				<tr>
					<th  align='center' width="15%">竞标文件提交记录表</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue15" class="fileQueue" flag="15" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify15" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==15}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				<tr>
					<th  align='center' width="15%">竞标单位竞价记录表</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue10" class="fileQueue" flag="10" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify10" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==10}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				<tr>
					<th  align='center' width="15%">交易结果</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue23" class="fileQueue" flag="23" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify23" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==23}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				<tr>
					<th  align='center' width="15%">中标通知书</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue24" class="fileQueue" flag="24" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify24" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==24}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
				<tr>
					<th  align='center' width="15%">其他资料</th>
					<td style="border-right: none" width="35%">
						<div id="fileQueue24" class="fileQueue" flag="25" style="margin: 10px 0px 0px 10px">
							<input type="file" name="uploadify" class="uploadify" id="uploadify25" data-options="required:true"/>
							<p style="color: #aaaaaa;width: auto">
							1、按住Ctrl可选择多个文件上传;<br/>
							2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
							</p>
						</div>
					</td>
					<td style="border-left: none" colspan="2">
						<c:forEach items="${resList}" var="res">
							<c:if test="${res.functionFlog==25}">
								<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
							</c:if>
						</c:forEach>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	
	$(function(){
		
		
	
	   // parent.$('#addEntityBt').hide();
		var resIds = "";
		<c:forEach items="${resList}" var="res">
		resIds += ",${res.id}";
		</c:forEach>
		$('#budgetMenuData').val(resIds);



		$(".uploadify").each(function() {
			upload=$(this).parent().parent().parent().find(".fileName");
			fileQueue=$(this).parent().parent().parent().find(".fileQueue");
			//alert(upload.val());
			$(this).uploadify({
				'height'        : 27,   
	            'width'         : 80,    
	            'buttonText'    : '选择附件',
	            'queueID': fileQueue.val(),//队列的ID
	            'queueSizeLimit':5,// 附件附列长度
				'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
				'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}',// 上传时请求的后台处理的controller
				'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
				'method':'post',  
				'folder': '',
				'preventCaching' : true,
				'fileTypeExts' :'*.jpg;*.png;*.gif;*.bmp;*.pdf',
				'auto': true,
				'multi': true,//是否可多选
				'removeCompleted' : false,
				'successTimeout' : 55555,
				'onUploadSuccess':function(file, data, response){
					$('#' + file.id).find('.data').html(' 上传完毕');
					$('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
					//alert("ww"+$('#' + file.id).parent().html());
					var cancel=$('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
					if (cancel) {
					   cancel.attr("rel", data);
					   cancel.click(function () {
						   var cancelData = cancel.attr("rel");
			               var  budgetMenuData = $('#budgetMenuData').val();
			               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
			               if(index != -1){
			            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
			            	   $('#budgetMenuData').val(budgetMenuData);
			               }
					   });
					}
				},
				'onUploadStart':function(file){
					//alert("ww"+$('#' + file.id).parent().parent().find(".uploadify").attr("id"));
					var uploadId=$('#' + file.id).parent().parent().find(".uploadify").attr("id");
					//var params=$('#' + file.id).parent().parent().parent().parent().find(".fileName").val();
					var functionFlog=$('#' + file.id).parent().parent().parent().parent().find(".fileQueue").attr("flag");
			        $("#"+uploadId).uploadify("settings","formData",{"functionFlog":functionFlog});
				},
				'onSelectError':function(file, errorCode, errorMsg){
					//alert(errorCode);
					switch(errorCode) {
						case -110:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
							this.queueData.errorMsg='所选文件大小超出系统限制!';
							break;
						case -120:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
							this.queueData.errorMsg='所选文件大小异常!';
							break;
						case -130:
							//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
							this.queueData.errorMsg='所选文件类型不正确!';
							break;
					}
				},
				'onCancel' : function(file){
					alert(file);
				}
			});
		});
		
	});


	//============
	function deleteFile(v,resId){
		var parent = v.parentNode;
		parent.parentNode.removeChild(parent);
		var  budgetMenuData = $('#budgetMenuData').val();
        var index = budgetMenuData.indexOf(","+resId)
        if(index != -1){
     	   budgetMenuData = budgetMenuData.replace(","+resId,"");
     	   $('#budgetMenuData').val(budgetMenuData);
        }

        //删除数据库中的文件信息
        $.ajax({
			type : "post",
			url : "${ctx}/business/projectmanage/deleteFile?resId="+resId,
			data : top.$("#addProjectsDataForm").serialize(),
			success : function(data){
				
			},
			error : function(data){
				alert("错误");
			}
		});
	}
	
	
	function viewDateClick(){
		$('#txtViewDate').datebox();
		$('.textbox-icon').click();
	}
	
	
</script>